package com.bxx.mapper;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.bxx.common.dto.BlogDto;
import com.bxx.entity.Blog;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

public interface BlogMapper extends BaseMapper<Blog> {
    @Select("SELECT `m_blog`.*,`m_class`.`name`,(SELECT count(`m_comment`.`id`) FROM `m_comment` WHERE `m_comment`.`blog_id`=`m_blog`.`id` ) sum FROM `m_blog`,`m_class` WHERE `m_blog`.`type`=`m_class`.`id` and title LIKE \"%${keyWord}%\" ORDER BY ${sortWord}")
    List<BlogDto> getBlogList(Page<BlogDto> page, String keyWord, String sortWord);
}
